﻿<script type="text/javascript">
    $(function () {
        $.najax({
            url: "/SystemManage/Organize/GetChildTreeSelectJson",
            success: function (ajaxResp) {
                var $trFirst = $('table tr:first');
                if ($trFirst.length != 1) {
                    return;
                }
                var $firstFormTitle = $trFirst.find('.formTitle:first');
                if (!($firstFormTitle.length && $firstFormTitle.length == 1)) {
                    return;
                }
                if (ajaxResp && ajaxResp.length) {
                    if (ajaxResp.length > 1) {
                        var html = '<th class="formTitle">医疗机构：</th>';
                        html += '<td class="formValue formDdlSelectorTd" style="width:110px;">';
                        html += '   <select id="OrganizeId" name="OrganizeId" class="form-control"><option value="">==请选择==</option></select>';
                        html += '</td>';
                        $(html).insertBefore($firstFormTitle);
                        $('#OrganizeId').bindSelect({
                            data: ajaxResp,
                            dropdownAutoWidth : true,
                            change: function () {
                                if (funcOrganizeIdChange) {
                                    funcOrganizeIdChange();
                                }
                            }
                        });
                    }
                    else if (ajaxResp.length == 1) {
                        $('<input id="OrganizeId" name="OrganizeId" style="display:none;" value="' + ajaxResp[0].id + '" type="text" />').insertBefore($trFirst.closest('table'));
                        if (funcOrganizeIdChange) {
                            funcOrganizeIdChange();
                        }
                    }
                }
                else {
                    //ajaxResp.length == 0 会进这

                }
            },
        });
    });
</script>